home *** CD-ROM | disk | FTP | other *** search
/ CD Concept 6 / CD Concept 06.iso / mac / UTILITAIRE / Little Smalltalk v3.1.4 / C Source / Sources / Callbacks.c next >
Text File  |  1995-01-26  |  2KB  |  71 lines

  1. /*
  2.     Little Smalltalk, version 3
  3.     Written by Tim Budd, Oregon State University, June 1988
  4.  
  5.     Symantec Think Class Library interface code 
  6.         ⌐Julian Barkway, August 1994 , all rights reserved.
  7.     
  8.     Callbacks.c 
  9.     -----------
  10.     This is a set of callback routines, mainly for processing dialogs.
  11. */
  12.  
  13. #include "Callbacks.proto.h"
  14. #include "LStResources.h"
  15.  
  16. //======================================================================================
  17. //    Highlight the default button by drawing a thick border around it.
  18. //======================================================================================
  19. pascal void highlightButton (DialogPtr dialog, short item)
  20. {
  21.     short            type;
  22.     Rect            box;
  23.     Handle            itemHdl;
  24.  
  25.     GetDItem (dialog, kSetButtonID, &type, &itemHdl, &box);
  26.     
  27.     PenSize (3, 3);
  28.     InsetRect (&box, -4, -4);
  29.     FrameRoundRect (&box, 16, 16);
  30.     PenNormal ();
  31.     
  32. }
  33.  
  34. //======================================================================================    DLOGfilterProc1 -        called from inside of ModalDialog
  35. //    Process button 1 as default, button 2 as Cancel (allows Return, Enter and 'cmd .')
  36. //======================================================================================
  37. pascal Boolean defaultButtonFilter (DialogPtr dialog, EventRecord *event, short *item)
  38. {
  39.     short    type;
  40.     Rect    box;
  41.     char    c;
  42.     long    endTicks;
  43.     Handle    itemHndl;
  44.     
  45.     c = (event->message & charCodeMask);
  46.     
  47.     switch (c) {
  48.         case 13:                        // <Return> or <enter>
  49.         case 3:
  50.             *item = kSetButtonID;
  51.             break;
  52.         case '.':                        // <Cmd .>
  53.             if (event->modifiers & cmdKey)
  54.                 *item = kCancelButtonID;
  55.             else
  56.                 return false;            // Just an ordinary dot. We're not interested.
  57.             break;
  58.         default:
  59.             return false;                // Not what we're after so give up
  60.     }
  61.     
  62.     GetDItem (dialog, *item, &type, &itemHndl, &box);
  63.     if (type == (ctrlItem | btnCtrl)) {
  64.         HiliteControl ((ControlHandle)itemHndl, true);
  65.         Delay (8, &endTicks);
  66.         HiliteControl ((ControlHandle)itemHndl, false);
  67.     }
  68.     event->what = mouseDown;
  69.     return true;
  70. }
  71.